package bean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.administrator.thread_test.R;

import java.util.ArrayList;
import java.util.List;

public class bookAdapter extends ArrayAdapter<book> {
    private int resourceId;

    public bookAdapter(Context context, int textViewResourceID, ArrayList<book> object)
    {
        super(context,textViewResourceID,object);
        resourceId = textViewResourceID;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        book book_temp = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        TextView book_name = (TextView)view.findViewById(R.id.book_name);
        book_name.setText(book_temp.getBook_name());
        TextView author = (TextView)view.findViewById(R.id.author);
        author.setText(book_temp.getAuthor());
        TextView count = (TextView)view.findViewById(R.id.count);
        count.setText(book_temp.getCount());
        TextView publish = (TextView)view.findViewById(R.id.publish);
        publish.setText(book_temp.getPublish());
        TextView publish_time = (TextView)view.findViewById(R.id.publish_time);
        publish_time.setText(book_temp.getPublish_time());
//        TextView book_index = (TextView)view.findViewById(R.id.book_index);
//        book_index.setText(book_temp.getBook_index());
        TextView item_url = (TextView)view.findViewById(R.id.item_url);
        item_url.setText(book_temp.getBook_link());
        return view;
    }

}
